<%-- 
    Document   : ViewCart
    Created on : Jul 21, 2011, 1:18:42 AM
    Author     : HOANG ANH
--%>
<%@page import="BUSObject.CartItem"%>
<%@page import="java.util.Iterator"%>
<jsp:useBean id="BeanCart" scope="session" class="BUS.BUSCart" />

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib tagdir="/WEB-INF/tags/template/" prefix="template" %>
<!DOCTYPE html>
<%
    Iterator<CartItem> list = BeanCart.getList();
%>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Your Cart</title>
    </head>
    <template:header level="0"></template:header>
    <template:StartContent level="0"></template:StartContent>
        <table border="1" cellspacing="3" cellpadding="1">
            <thead>
                <tr>
                    <th>Product ID</th>
                    <th>Product Name</th>
                    <th>Quality</th>
                    <th>Price</th>
                    <th>Cost</th>
                    <th></th>
                    <th></th>
                </tr>
            </thead>
            <tbody>
            <%
                for (Iterator<CartItem> it = list; it.hasNext();) {
                    CartItem cartItem = it.next();
            %>

            <tr>
                <td><%= cartItem.getID()%></td>
                <td><%= cartItem.getName()%></td>
                <td><%= cartItem.getQuantity()%></td>
                <td><%= cartItem.getPrice()%></td>
                <td><%= cartItem.getPrice() * cartItem.getQuantity()%></td>
            <form action="EditCartItem.jsp" method="POST">
                <td>
                    <input type="text" name="quantity" value="<%=cartItem.getQuantity()%>" style="width: 55px"/>
                    <input type="submit" value="Change Quantity" name="Button"/>
                </td>   
                <td>
                    <input type="submit" value="Remove" name="Button"/>
                    <input type="hidden" name="ID" value="<%= cartItem.getID()%>" />
                </td>
            </form>
            </tr>
            <%}%>
</tbody>
</table>

<b>Total Cost : <jsp:getProperty name="BeanCart" property="cost" /></b>
<br/>
<a href="User/CheckOut.jsp">Check Out</a>
<template:EndContent></template:EndContent>
<template:Footer></template:Footer>
</html>
